// pages/myOrder/myOrder.js
var usedata = require("../myOrderdata/myOrderdata.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    myOrderdata:'',
    navData: [
      {
        text: '未配送'
      },
      {
        text: '在配送'
      },
      {
        text: '已完成'
      },
    ],
    currentTab: 0,
    navScrollLeft: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      myOrderdata: usedata.myOrderdata
    })
  },
  switchNav(event) {
    var cur = event.currentTarget.dataset.current;
    //每个tab选项宽度占1/3
    var singleNavWidth = this.data.windowWidth / (this.data.navData.lenght);
    //tab选项居中                            
    this.setData({
      navScrollLeft: (cur - 2) * singleNavWidth
    })
    if (this.data.currentTab == cur) {
      return false;
    } else {
      this.setData({
        currentTab: cur
      })
    }
  },
  switchTab(event) {
    var cur = event.detail.current;
    var singleNavWidth = this.data.windowWidth / (this.data.navData.lenght);
    this.setData({
      currentTab: cur,
      navScrollLeft: (cur - 2) * singleNavWidth
    });
  }
})